﻿/*
 * Programmer: JR Padfield
 * Project: Crzy Math Date
 * Description: Gets and sets the month, year and days in month to keep track of things
 * Version: 1
 * Date: 05/27/2013
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Crzy_Math
{
    public class Date
    {
        #region Date Fields

        private DateTime date = new DateTime();
        private int daysInMonth;
        private int currentYear;
        private int currentMonth;

        #endregion

        #region Date Properties

        public int DaysInMonth
        {
            get { return daysInMonth; }
            set { daysInMonth = value; }
        }

        public int CurrentYear
        {
            get { return currentYear; }
            set { currentYear = value; }
        }

        public int CurrentMonth
        {
            get { return currentMonth; }
            set { currentMonth = value; }
        }

        #endregion

        #region Date Methods

        /// <summary>
        /// Sets current year. Only called when current year is not set or if its a new year.
        /// </summary>
        public void SetCurrentYear()
        {
            CurrentYear = date.Year;
        }

        /// <summary>
        /// Sets current month. Only called when current month is not set or if its a new month.
        /// </summary>
        public void SetCurrentMonth()
        {
            CurrentMonth = date.Month;
        }

        /// <summary>
        /// Retrives the days in a month.
        /// </summary>
        /// <returns>X amount of days in the month</returns>
        public int GetDaysInMonth()
        {
            DaysInMonth = DateTime.DaysInMonth(currentYear, currentMonth);

            return daysInMonth;
        }

        /// <summary>
        /// Checks to see if is a new year.
        /// </summary>
        /// <returns>True or false</returns>
        public bool IsNewYear()
        {
            if (CurrentYear != date.Year)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// Checks to see if is a new month
        /// </summary>
        /// <returns>True or False</returns>
        public bool IsNewMonth()
        {
            if (CurrentMonth != date.Month)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        #endregion
    }
}
